home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_08 / letters / pstring.h < prev   
C/C++ Source or Header  |  1994-06-20  |  2KB  |  52 lines

  1. @CSOURCE6 = /* <R>
  2.  *Header: pstring.h (string handling support)<R>
  3.  *    by Martin.Weitzel@rent-a-guru.DE<R>
  4.  */<R>
  5. #ifndef PSTRING_H<R>
  6. #define PSTRING_H<R>
  7. /*<R>
  8.  * Interface macros to "pstr_x" for fixed number of<R>
  9.  * arguments. (Using this macros instead of direct<R>
  10.  * calls to the function helps to make the source<R>
  11.  * more readable.)<R>
  12.  */<R>
  13. char *pstr_x(const char *str, ...);<R>
  14. #define pstr_1(s1)\<R>
  15.     (pstr_x(s1, (const char *)0))<R>
  16. #define pstr_2(s1, s2)\<R>
  17.     (pstr_x(s1, s2, (const char *)0))<R>
  18. #define pstr_3(s1, s2, s3)\<R>
  19.     (pstr_x(s1, s2, s3, (const char *)0))<R>
  20. #define pstr_4(s1, s2, s3, s4)\<R>
  21.     (pstr_x(s1, s2, s3, s4, (const char *)0))<R>
  22. /* .... may be extended .... */<R>
  23. <R>
  24. /*<R>
  25.  * Strings that are used only once may be build with<R>
  26.  * help of the "tmpstr"-function or (preferably) with<R>
  27.  * one of the "TMPSTR"-macros. The space occupied by<R>
  28.  * a string build in this way is freed with the next<R>
  29.  * call to one of this macros, so its contents should<R>
  30.  * be accessed IMMEDIATELY. To reduce the risk of<R>
  31.  * inappropriate use, the result of calls to "tmpstr"<R>
  32.  * should NEVER be stored into a pointer, and when<R>
  33.  * calling a function that needs several string<R>
  34.  * arguments, AT MOST ONE may be initialized with the<R>
  35.  * result of a call to "tmpstr". In both cases this<R>
  36.  * includes indirect calls to "tmpstr" through one of<R>
  37.  * the "TMPSTR"-macros.<R>
  38.  */<R>
  39. char *tmpstr(char *str);<R>
  40. #define TMPSTR1(s1)\<R>
  41.     (tmpstr(pstr_1(s1)))<R>
  42. #define TMPSTR2(s1, s2)\<R>
  43.     (tmpstr(pstr_2(s1, s2)))<R>
  44. #define TMPSTR3(s1, s2, s3)\<R>
  45.     (tmpstr(pstr_3(s1, s2, s3)))<R>
  46. #define TMPSTR4(s1, s2, s3, s4)\<R>
  47.     (tmpstr(pstr_4(s1, s2, s3, s4)))<R>
  48. /* .... may be extended .... */<R>
  49. <R>
  50. #endif
  51.  
  52.